package org.ice4apps.master.dao;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Office entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "office", catalog = "icemaster", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public class Office implements java.io.Serializable {
    // Fields
    private String           id;
    private Organization     organization;
    private String           name;
    private Long             features;
    private Long             creationdate;
    private Long             updationdate;
    private Set<OfficeAdmin> officeAdmins = new HashSet<OfficeAdmin> (0);
    private Set<User>        users        = new HashSet<User> (0);

    // Constructors
    /** default constructor */
    public Office () {
    }

    /** minimal constructor */
    public Office (String id,
                   Organization organization,
                   String name,
                   Long creationdate) {
        this.id = id;
        this.organization = organization;
        this.name = name;
        this.creationdate = creationdate;
    }

    /** full constructor */
    public Office (String id,
                   Organization organization,
                   String name,
                   Long features,
                   Long creationdate,
                   Long updationdate,
                   Set<OfficeAdmin> officeAdmins,
                   Set<User> users) {
        this.id = id;
        this.organization = organization;
        this.name = name;
        this.features = features;
        this.creationdate = creationdate;
        this.updationdate = updationdate;
        this.officeAdmins = officeAdmins;
        this.users = users;
    }

    // Property accessors
    @Id
    @Column(name = "id", unique = true, nullable = false, length = 36)
    public String getId () {
        return this.id;
    }

    public void setId (String id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "organization", nullable = false)
    public Organization getOrganization () {
        return this.organization;
    }

    public void setOrganization (Organization organization) {
        this.organization = organization;
    }

    @Column(name = "name", unique = true, nullable = false, length = 36)
    public String getName () {
        return this.name;
    }

    public void setName (String name) {
        this.name = name;
    }

    @Column(name = "features")
    public Long getFeatures () {
        return this.features;
    }

    public void setFeatures (Long features) {
        this.features = features;
    }

    @Column(name = "creationdate", nullable = false)
    public Long getCreationdate () {
        return this.creationdate;
    }

    public void setCreationdate (Long creationdate) {
        this.creationdate = creationdate;
    }

    @Column(name = "updationdate")
    public Long getUpdationdate () {
        return this.updationdate;
    }

    public void setUpdationdate (Long updationdate) {
        this.updationdate = updationdate;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "office")
    public Set<OfficeAdmin> getOfficeAdmins () {
        return this.officeAdmins;
    }

    public void setOfficeAdmins (Set<OfficeAdmin> officeAdmins) {
        this.officeAdmins = officeAdmins;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "office")
    public Set<User> getUsers () {
        return this.users;
    }

    public void setUsers (Set<User> users) {
        this.users = users;
    }
}